test(fhir): add regression tests for empty and dangling-reference Bundle edges#556
Merged
maziyarpanahi merged 2 commits intoJun 22, 2026
Merged
Conversation
…dle edges Lock in two behaviors of to_bundle() that were correctly implemented but not explicitly tested: - Empty input returns a well-formed Bundle with empty entry list for transaction, collection, and batch bundle types. - References to resources absent from the Bundle are preserved verbatim (not rewritten). Tests cover single, mixed internal/ external, and multiple dangling references on one resource. Closes maziyarpanahi#547. Signed-off-by: axelray-dev <110029405+axelray-dev@users.noreply.github.com>
maziyarpanahi
approved these changes
Jun 22, 2026
maziyarpanahi
left a comment
Owner
There was a problem hiding this comment.
Thank you @axelray-dev. I reviewed this against #547 / OM-362 and added one small maintainer follow-up commit: test: format FHIR bundle edge cases.
What I changed:
- removed an unused import in the new edge-case test file;
- applied the repository Ruff formatter to wrap the long dangling-reference assertion.
The test coverage itself matches the issue: empty resource lists produce well-formed empty Bundles for the requested bundle types, dangling references are preserved verbatim, and mixed internal/dangling references keep the existing rewrite behavior for resources present in the Bundle.
Verification on the current PR checkout:
PYTHONPATH=/private/tmp/openmed-pr-556 /Users/maziyar/Developer/openmed/.venv/bin/python -m pytest tests/unit/clinical/test_fhir_bundle_edge_cases.py tests/unit/clinical/test_fhir_bundle.py -q-> 18 passed/Users/maziyar/Developer/openmed/.venv/bin/ruff check tests/unit/clinical/test_fhir_bundle_edge_cases.py tests/unit/clinical/test_fhir_bundle.py-> passed/Users/maziyar/Developer/openmed/.venv/bin/ruff format --check tests/unit/clinical/test_fhir_bundle_edge_cases.py tests/unit/clinical/test_fhir_bundle.py-> passed
I also copied the labels from #547 onto the PR. The branch is mergeable with no conflicts; GitHub has not attached hosted checks to the new head commit yet, so I verified the touched behavior locally.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #547.
Lock in two behaviors of
to_bundle()that were correctly implemented but not explicitly tested:Test-only change. No source code modifications. All 18 tests pass (6 new + 12 existing).